#ifndef CDBINTERFACE_H
#define CDBINTERFACE_H

#include "caribbeancommon.h"

class ProgressiveTrackSQL;
struct CInfo;
class CStudServer;
class CPokerConnection;
class CGame;


//**********************************************************************************************************
//
//  This class serves to define the interface used by the CPokerConnection to talk to objects 
//  that implement game specific database code (e.g., CHoldemSQL and CStudSQL).  
//
//  Additionally, some common logic which is database related, but isn't game specific also 
//  lives in this class.
//
//  There'll be an instance of a class derived from this for every player session on this poker server.
//
//  kharmon.  09-28-05.  #5861.
// 
//**********************************************************************************************************

class CDBInterface
{
public:

    CDBInterface(ProgressiveTrackSQL *pTracker, CInfo *pInfo);    

    // called everytime a new game is begun.
	virtual bool8 trackNewGame(int32 Bet, int32 progressiveBet, int32 multiBankBet, 
                               int32* Balance, uint8 payTable, int32 compFactor) = 0;

    // called when the user requests that cards be dealt, usually right after trackNewGame.
    virtual bool8 trackDeal(CGame *pGame) = 0;

    // called when the final status of a game has been determined.
    virtual bool8 trackGameDone(bool8 Raised, int32 PayAnte, int32 PayRaise, int32 PayProgressive,
					            int32 PayMultiBank, int32 Outcome, int32 BalAdjust, int32 *Balance, 
                                bool8 bMalfunction, CGame *pGame) = 0;       // kharmon.  10-12-06.  #8226.  No longer save cards in database before the game is complete.

    // called to load any saved game that the current user might have laying around.
	virtual bool8 trackHasSavedGame(CPokerConnection *pConn, CGame ** ppGame, int32 * err) = 0;

    // called to (theoretically) save the game state to the database after the cards are dealt.
	virtual bool8 trackSaveGame(CGame *pGame) = 0;

    // called to load the casino settings for the implementing game
    virtual bool8 trackGetOptions(bool8* progressiveOn, uint8* progPayTable, 
                                  int32* progJackpotID, uint8* payTable, int32* progressiveFixAmountMultiplier) = 0;

    // get the current user's balance
	virtual bool8 trackGetBalance(int32 *);

    // change the current user's balance
	virtual int32 trackAdjustBalance(int32);

    // get min/max betting limit info for the indicated game.
	virtual bool8 trackGetPlayerLimits(CaribbeanGameId eGameId, int32* minBet, 
                                       int32* maxBet, int32* compFactor);    

    // complete the login process for the current player (using the data in the CInfo object).
    virtual int32 trackValidateLogin();

	// verify the player's session is still active
    virtual int32 trackValidateSession();

protected:

    ProgressiveTrackSQL *m_pTracker;    // provides connections to the database and has other useful abilities.
    CInfo               *m_pInfo;       // info about the current player session

};





#endif